package com.yitiao.data_algorithms.leetcode.editor.cn;

import com.yitiao.data_algorithms.leetcode.editor.cn.base.ListNode;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.TreeNode;

class CoinChange2 {
    // 2022-09-07 11:37:45
    public static void main(String[] args) {
        Solution solution = new CoinChange2().new Solution();
        solution.change(5, new int[]{1, 2, 5});
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int change(int amount, int[] coins) {
            int[] dp = new int[amount + 1];
            dp[0] = 1;
            int ans = 0;
            for (int j = 0; j < coins.length; j++) {
                for (int i = coins[j]; i <= amount; i++) {

                    dp[i] += dp[i - coins[j]];
                }
            }
            return dp[amount];
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}